package com.example.music.fragment

import android.os.Bundle
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.example.lib_common_ui.base.BaseFragment
import com.example.lib_leancloud.LeanCloudManager
import com.example.music.ViewModel.MainViewModel
import com.example.music.adapter.chartAdapter
import com.example.music.databinding.FragmentHomeBinding


class HomeFragment : BaseFragment<FragmentHomeBinding>() {
    private val mainViewModel: MainViewModel by activityViewModels()
    private val mAdapter = chartAdapter()
    override fun initUI(savedInstanceState: Bundle?) {
        LeanCloudManager.instance.chartMusicModelList.observe(viewLifecycleOwner) {
            mAdapter.setNewData(it)
        }
        initRecyclerView()
    }

    private fun initRecyclerView() {
        mBinding.recycler.adapter = mAdapter
        mBinding.recycler.layoutManager = LinearLayoutManager(requireContext())
    }
}